
var app = new Vue({
  el: '#app',
  data: {
    List:[{
      title:"启程",
      children:[{
        label:"启程",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/dq7adawn1w5qek6l?singleDoc# 《配置》"
      }]
    },{
      title:"组件",
      children:[{
        label:"按钮",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/qn68ir4328gaza3g?singleDoc# 《按钮》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/button"
      },{
        label:"短信倒计时",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/ewdzkgwyhvaq1bg7?singleDoc# 《短信倒计时》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/code-time"
      },{
        label:"图片上传",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/uagm3h85yhef6sg9?singleDoc# 《图片上传》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/upload-img"
      },{
        label:"步进器",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/eni3t9hhl2mooqpl?singleDoc# 《步进器》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/input-number"
      },{
        label:"分割线",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/vnge5aspb0gbx6le?singleDoc# 《分割线》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/divider"
      },{
        label:"角标",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/xadu59bzaffg15h0?singleDoc# 《角标》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/badge"
      },{
        label:"价格",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/oo8xfdls9pyqn1qg?singleDoc# 《价格》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/price"
      },{
        label:"tab切换",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/ps7c39eetgvx5yea?singleDoc# 《tab切换》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/tab"
      },{
        label:"图片懒加载",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/kd8foapswcm6wmla?singleDoc# 《图片懒加载》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/lazy-load"
      },{
        label:"自定义导航栏",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/qawm7ebee8bughrh?singleDoc# 《自定义导航栏》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/bar"
      },{
        label:"抽屉",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/sku7eh4lgtrgo114?singleDoc# 《抽屉》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/actionsheet"
      },{
        label:"模态框",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/esy9sit87avo3luu?singleDoc# 《模态框》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/dialog"
      },{
        label:"倒计时",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/wzfb5x3gyf9n4oyn?singleDoc# 《倒计时》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/countdown"
      },{
        label:"下拉刷新",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/gdl5s2gcwpzay0xd?singleDoc# 《下拉刷新》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/refresh"
      },{
        label:"日期选择器",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/phd3ey6b7sl3zfyw?singleDoc# 《日期选择器》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/picker-date"
      },{
        label:"输入框",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/znv74173yk5wv0cb?singleDoc# 《输入框》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/components/input"
      }]
    },{
      title:"插件",
      children:[{
        label:"时间戳格式化",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/zm5gafzghnqx7sy7?singleDoc# 《时间戳格式化》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/timeFormat"
      },{
        label:"小数点精确位",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/gd4kwblom6hmpti2?singleDoc# 《小数点精确位》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/tofixed"
      },{
        label:"随机数",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/yldlbm4kckcwkgop?singleDoc# 《随机数》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/random"
      },{
        label:"数字转汉字",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/xky9l7nfv0ugg6ow?singleDoc# 《数字转汉字》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/numberHave"
      },{
        label:"数字转大写",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/vkgp4gz1wx0gha03?singleDoc# 《数字转大写》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/toCapital"
      },{
        label:"号码保护",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/eg49i9uog3nt06sk?singleDoc# 《号码保护》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/telProtect"
      },{
        label:"深拷贝",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/ob5cb0ht10mhde26?singleDoc# 《深拷贝》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/deepCopy"
      },{
        label:"http请求",
        url:"https://www.yuque.com/xiaoxiaoderen-xd7rx/rsfukv/lo9vhvnohq681gik?singleDoc# 《http请求》",
        M_url:"https://zzjzml.atomgit.net/ufast-next-preview/#/pages/utssdk/request"
      }]
    }],
    copyList:[],
    url:"",
    value:"",
    win:null,
    key:0,
    keyChild:0
  },
  methods: {
    toPage:function(key,keyChild){
      var that = this
      this.key = key
      this.keyChild = keyChild
      this.List.map(function(v,k){
        v.children.map(function(v2,k2){
          var item = v2
          item.active = (k == key && k2 == keyChild) ? true : false
          that.$set(v.children,k2,item)
        })
      })
      this.url = this.List[key].children[keyChild].url
    },
    preview:function(){
       if(this.List[this.key].title !== '启程'){
        var screenWidth = window.outerWidth || document.documentElement.clientWidth || document.body.clientWidth;
        var screenHeight = window.outerHeight || document.documentElement.clientHeight || document.body.clientHeight;
        var width = 375
        var height = 650
        var left = screenWidth - 20;
        var top = screenHeight - 60;
        var windowFeatures = `width=${width},height=${height},left=${left},top=${top}`;
        if(this.win){
          this.win.close()
        }
        this.win = window.open(this.List[this.key].children[this.keyChild].M_url, '_blank', windowFeatures);
      }
    },
    toLink:function(url){
      window.open(url,'_black')
    }
  },
  watch:{
    value:function(bind){
      var copyList = JSON.parse(JSON.stringify(this.copyList))
      copyList.map(function(v){
        v.children = v.children.filter(function(v2){
          return v2.label.indexOf(bind) >= 0
        })
      })
      this.List = JSON.parse(JSON.stringify(copyList))
    }
  },
  mounted:function(){
    this.toPage(0,0,true)
    this.copyList = JSON.parse(JSON.stringify(this.List))
  }
})